#ifndef PROTOCOL_H
#define PROTOCOL_H

#include <stdlib.h>
#include <unistd.h>
#include <string.h>

typedef unsigned int uint;

#define REGIST_OK "Regist ok"
#define REGIsT_FAILED "Regist failed : name existed"
#define LOGIN_OK "Login ok"
#define LOGIN_FAILED "Login failed : name not existed"
#define CANCEL_OK "Cancel ok"
#define CANCEL_FAILED "Cancel failed : name not existed"

enum ENUM_MSG_TYPE
{
    ENUM_MSG_TYPE_MIN = 0,
    ENUM_MSG_TYPE_REGIST_REQUEST,  //注册请求
    ENUM_MSG_TYPE_REGIST_RESPOND,  //注册回复
    ENUM_MSG_TYPE_LOGIN_REQUEST,  //登录请求
    ENUM_MSG_TYPE_LOGIN_RESPOND,  //登录回复
    ENUM_MSG_TYPE_CANCEl_REQUEST,  //注销请求
    ENUM_MSG_TYPE_CANCEL_RESPOND,  //注销回复
    // ENUM_MSG_TYPE_REQUEST,
    // ENUM_MSG_TYPE_RESPOND,
    // ENUM_MSG_TYPE_REQUEST,
    // ENUM_MSG_TYPE_RESPOND,
    ENUM_MSG_TYPE_MAX = 0x00ffffff,
};

struct PDU
{
    uint  uiPDULen;
    uint uiMsgType;
    char caData[64];
    uint uiMsgLen;
    int caMsg[];
};

PDU *mkPDU(uint uiMsgLen);

#endif // PROTOCOL_H
